package client

import akka.actor._
import akka.remote.RemoteScope
import server.ServerActor

/**
  * Created by shouf on 2016/5/16.
  */
class ClientActor extends Actor{
//  val serverActor: ActorSelection = context.actorSelection("akka.tcp://serverSys@127.0.0.1:5155/user/serveractor")  //the first way to create actor
//  serverActor ! "call me "
  val address = Address("akka.tcp", "serverSys", "127.0.0.1", 5155)
//  val serverActor: ActorRef = context.actorOf(Props[ServerActor].withDeploy(Deploy(scope = RemoteScope(address))))//the 2nd way to create actor
  val serverActor = context.system.actorOf(Props[ServerActor], name = "serverActor") //the 3st way to create actor
 println(s"actor create ${serverActor.path}")
  def receive = {
    case "START" => println("START!"); serverActor ! "send by local!"
    case str:String =>
      println(s"client received ${str}, this is local")
      serverActor ! "call server"
  }
}
